package com.plumejob.boot.autoconfigure;

import com.plumejob.boot.SpringContextUtil;
import com.plumejob.boot.properties.PlumejobProperties;
import com.plumejob.executor.PlumeJobContext;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
 * @author : pdl
 * @date : 2021/2/8 11:20
 */
@EnableConfigurationProperties(value = PlumejobProperties.class)
@Import(SpringContextUtil.class)
public class PlumejobAutoConfiguration {

    @Autowired
    private PlumejobProperties plumejobProperties;

    @Bean
    public void Plumejob() throws SchedulerException {
        PlumeJobContext.init(plumejobProperties.getAppName(), plumejobProperties.getHost(), plumejobProperties.getPoolSize());
        PlumeJobContext.start(plumejobProperties.getBasePackages());
    }
}
